package com.tarena.lbs.content.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.content.pojo.param.ArticleContentParam;
import com.tarena.lbs.content.pojo.vo.ArticleCategoryVO;
import com.tarena.lbs.content.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 处理文章分类 业务模块功能
 */
@Tag(name = "文章分类管理")
@Slf4j
@RestController
@RequestMapping("/admin/content/category")
public class CategoryController{

    @Autowired
    private CategoryService categoryService;

    /**
     * 插入分类
     * ~
     * @return
     */
    @Operation(summary = "文章分类列表查询")
    @GetMapping("/admin/content/category/list")
    public Result<PageResult<ArticleCategoryVO>> pageList(@ModelAttribute ArticleCategoryVO query){

       log.debug("文章分类列表,{}",query);
       // TODO
//       PageResult<ArticleCategoryVO>voPage =categoryService.pageList(query);
//       return new Result<>(voPage);
       return null;
    }
    @Operation(summary = "新增文章分类")
    @PostMapping("/inseert")
    public Result<Void>AddCategory(@ModelAttribute ArticleContentParam param){
        // TODO
//        log.debug("新增文章分类：{}",param);
//        categoryService.addCateory(param);
        return Result.success();
    }
    @Operation(summary = "更新文章分类")
    @PostMapping("/update")
    public Result<Void>Updategory(@ModelAttribute ArticleContentParam param){
        // TODO
//        log.debug("更新文章分类：{}",param);
//        categoryService.updateCategory(param);
        return Result.success();
    }
    @Operation(summary = "删除文章分类")
    @PostMapping("/delete")
    public Result<Void>DeleteCategory(@RequestBody ArticleContentParam param){
        log.debug("删除文章分类：{}",param);
        categoryService.deleteCategory(param.getId());
        return Result.success();
    }
}